import ccRequest from '../index'
import { IAccount, ISpringSecurityLoginResult, ISpringSecurityLoginUserModel } from './types'
import { IDataType, ILoginResult } from './types'

enum LoginAPI {
  AccountLogin = '/login/in',
  LoginUserInfo = '/users', // 用法：users/1
  LoginUserInfoM = '/sysUser/selectByPrimaryKey', // /sysUser/selectByPrimaryKey/2
  UserMenus = '/role', // 用法：/role/1/menu
  UserMenusM = '/vue3menu/menus' // 没有参数
}

export function accountLoginRequest(account: ISpringSecurityLoginUserModel) {
  return ccRequest.post<IDataType<ISpringSecurityLoginResult>>({
    // headers: {
    //   'Content-Type': 'multipart/form-data'
    // },
    url: LoginAPI.AccountLogin,
    data: account
  })
}

export function reqLoginUserInfo(userId: number) {
  return ccRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfoM + '/' + userId,
    showLoading: false
  })
}

export function reqUserMenus(userId: number) {
  return ccRequest.get<IDataType>({
    // url: LoginAPI.UserMenus + '/' + userId + '/menu',
    url: LoginAPI.UserMenusM,
    showLoading: false
  })
}

export function testReq() {
  return ccRequest.post({
    url: 'http://49.234.149.119:7705/xzy/dev/computer'
  })
}
